package com.laamella.syntherface.synths.alesis.micron.model;

import com.laamella.syntherface.synths.midi.MidiInterface;
import com.laamella.syntherface.synths.models.NrpnParameterModel;
import com.laamella.syntherface.synths.models.ParameterType;

/**
 * Parameters for a single LFO.
 */
public final class Lfo {
	public final NrpnParameterModel tempoSync;
	public final NrpnParameterModel rateFree;
	public final NrpnParameterModel rateSynced;
	public final NrpnParameterModel reset;
	public final NrpnParameterModel m1SliderToLfo;

	public static final ParameterType FreeRateType = new ParameterType(0, 1023) {
		@Override public String format(int value) {
			return ""+value;
		}
	};
	
	public static final ParameterType TempoRateType = new ParameterType.List("x 1/16 (4 whole), x 1/12 (dot 2 whole), x 3/32 (4 whole triplets), x 1/8 (2 whole), x 1/6 (dot whole)"+
			"x 3/16 (2 whole triplets), x 1/4 (whole), x 1/3 (dot half), x 3/8 (whole triplet), x 1/2 (half note), x 2/3 (dot quarter), x 3/4 (half triplet), "+
			"x 1 (quarter), x 1 1/3 (dot 8), x 1 1/2 (quarter triplet), x 2 (8th note), x 2 2/3 (dot 16), x 3 (8th triplet), x 4 (16th note),"+
			"x 5 1/3 (dot 32), x 6 (16th triplet), x 8 (32nd note), x 10 2/3 (dot 64), x 12 (32nd triplet), x 16 (64th note)");

	public static final ParameterType ResetType=new ParameterType.List("mono (per program), poly (per voice), key mono, key poly, legato mono, legato poly, tempo lock");
	
	public Lfo(MidiInterface midiInterface, int number) {
		int offset = (number - 1) * 4;
		String name = "lfo " + number + " ";
		tempoSync = new NrpnParameterModel(name + "tempo sync", midiInterface, 105 + offset, new ParameterType.Boolean("fixed rate", "follow tempo"));
		rateFree = new NrpnParameterModel(name + "rate (free)", midiInterface, 106 + offset, FreeRateType);
		rateSynced = new NrpnParameterModel(name + "rate (follow tempo)", midiInterface, 159 + offset, TempoRateType);
		reset = new NrpnParameterModel(name + "reset", midiInterface, 107 + offset, ResetType);
		m1SliderToLfo = new NrpnParameterModel("m1 slider influence" + name, midiInterface, 108 + offset, ParameterType.Percentage);
	}
}